<?php declare(strict_types=1);

use Hyperf\HttpServer\Router\Router;

use App\Bac\Controller\ConfigController;
use App\Bac\Controller\HomeController;
use App\Bac\Controller\PrixController;

Router::addGroup('', function () {

    // RBAC 相关
    include __DIR__ . '/rbac.php';

    // 首页数据统计
    Router::get('/dashboard', [HomeController::class, 'dashboard']);

    // 管理员修改密码
    Router::post('/update-password', [HomeController::class, 'updatePassword']);

    // 文件上传
    Router::post('/upload', [HomeController::class, 'upload']);

    // 配置接口
    Router::addGroup('/config', function () {
        Router::get('', [ConfigController::class, 'list']);
        Router::get('/map', [ConfigController::class, 'map']);
        Router::post('', [ConfigController::class, 'create']);
        Router::put('/{id:\d+}', [ConfigController::class, 'update']);
        Router::delete('/{id:\d+}', [ConfigController::class, 'delete']);
    });

    // 业务接口
    Router::get('/daily_statistics', [HomeController::class, 'daily_statistics']);
    Router::get('/order', [HomeController::class, 'order_list']);
    Router::get('/game_log', [HomeController::class, 'game_log_list']);
    Router::get('/room_log', [HomeController::class, 'room_log_list']);
    Router::get('/club', [HomeController::class, 'club_list']);
    Router::get('/user', [HomeController::class, 'user_list']);
    Router::get('/update_itme', [HomeController::class, 'update_itme']);
    Router::get('/info_details', [HomeController::class, 'info_details']);
    Router::get('/banned', [HomeController::class, 'banned']);
    Router::get('/log_club_warehouse', [HomeController::class, 'log_club_warehouse']);
    Router::get('/log_backpack', [HomeController::class, 'log_backpack']);
    Router::get('/log_physical_exchange', [HomeController::class, 'log_physical_exchange']);
    Router::post('/update_address', [HomeController::class, 'update_address']);

    // 线下大奖赛相关路由配置
    Router::addGroup('/prix', function () {
        Router::get('', [PrixController::class, 'list']);
        Router::post('', [PrixController::class, 'create']);
        Router::put('/{id:\d+}', [PrixController::class, 'update']);
        Router::delete('/{id:\d+}', [PrixController::class, 'delete']);

        Router::addGroup('/section', function () {
            Router::get('/{pid:\d+}', [PrixController::class, 'listSection']);
            Router::get('/create/{pid:\d+}', [PrixController::class, 'createSection']);
            Router::put('/{id:\d+}', [PrixController::class, 'updateSection']);
            Router::delete('/{pid:\d+}_{idx:\d+}', [PrixController::class, 'listSection']);
        });

        Router::addGroup('/member', function () {
            Router::get('/{sid:\d+}', [PrixController::class, 'listMember']);
            Router::post('/edit_attr', [PrixController::class, 'updateAttr']);
            Router::post('/edit_seat', [PrixController::class, 'updateSeat']);
            Router::get('/clear_seat/{sid:\d+}_{circle}', [PrixController::class, 'clearSeat']);
        });
    });

}, ['middleware' => App\Bac\Middleware\PermissionMiddleware::class]);

